package customview.ike.com.customviewproject.aop;

import android.Manifest;
import android.annotation.TargetApi;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.os.HandlerThread;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.FrameLayout;

import java.util.ArrayList;
import java.util.List;

import customview.ike.com.customviewproject.R;
import customview.ike.com.customviewproject.aop.RequestPermission.RequestPermission;
import customview.ike.com.customviewproject.utils.permission.PermissionHelper;

/**
 *@author:ike
 *@function: aop 测试权限申请的Activity
 *@creat time:17:47 2018/1/30
 **/

public  class AopPermissionActivity extends AppCompatActivity{
    public static final int CODE_CAMERA=1;
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_permission);
        getSupportFragmentManager().beginTransaction()
                .add(R.id.permission_frag,new PermissionFragmnet())
                .commit();
    }
    @RequestPermission(
            value = {android.Manifest.permission.CAMERA, Manifest.permission.CALL_PHONE},
            requestCode = CODE_CAMERA)
    public void openCamera(View view){
        Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
        startActivityForResult(intent,3);
    }

    @TargetApi(Build.VERSION_CODES.M)
    @Override
    public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
        PermissionHelper.getInstance().handleRequestPermissionsResult(requestCode,permissions,grantResults);
        super.onRequestPermissionsResult(requestCode, permissions, grantResults);
    }
   
}
